<template>
  <div>
    <!-- <text-scroll :text-time="500" :time="2000"></text-scroll> -->
    <zc-table
      v-bind="config"
      :is-collpase="true"
      :request="request"
      :total="total"
      :pagination="{
        total: true,
        sizes: true,
        jumper: true,
      }"
      pagination-align="right"
    >
    </zc-table>
    <zc-dialog v-bind="DConfig" v-model:visible="dialogVisible">
      <template #content> 我是主体内容 </template>
    </zc-dialog>
  </div>
</template>

<script setup lang="ts">
import config from "./indexTableConfig";
import DConfig from "./indexDialogConfig";
import { getWarningList, WarningParams } from "@/api/preWarning";
import dayjs from "dayjs";
let dialogVisible = ref<boolean>(false);
const total = ref(0);
const request: (
  params: Partial<WarningParams> & { startTime: string; endTime: string }
) => Promise<any> = async (params) => {
  if (params.eventTime) {
    const startTime = dayjs(params.eventTime[0]).format("YYYY-MM-DD HH:mm:ss");
    const endTime = dayjs(params.eventTime[1]).format("YYYY-MM-DD HH:mm:ss");
    params.startTime = startTime;
    params.endTime = endTime;
    delete params.eventTime;
  }

  const res = await getWarningList(params);
  total.value = res?.total;
  return res?.records;
};
onMounted(() => {
  console.log("index");
});
</script>

<style scoped lang="scss">
.header-default {
  display: flex;
  justify-content: end;
}
</style>
